<?php
$language = $this->requestAction('languages/show');
?>

<ul class="nav navbar-nav pull-right">
    <li class="dropdown">
        <a data-toggle="dropdown" href="#">
            <?php 
            echo $this->Session->read('Language.name');
            ?>
            <b class="caret"></b></a>
        <ul class="dropdown-menu">
            <?php 
            foreach ($language as $lang):
                //echo '<li><a href="./languages/lang?l='.$lang['Language']['code'].'">'.$lang['Language']['name'].'</a></li>';
                echo '<li>';
                echo $this->Html->link($lang['Language']['name'], array(
                    'controller'=>'languages',
                    'action'=>'lang',
                    'full_base'=>'true',
                    '?'=>array('l'=>$lang['Language']['code'])
                ));
                echo '</li>';
            endforeach;
            ?>
        </ul>
    </li>
</ul>